package array

func Sum(nums []int) (sum int) {
	for _, v := range nums {
		sum += v
	}
	return
}

func SumAll(slices ...[]int) (sums []int) {
	for _, nums := range slices {
		sums = append(sums, Sum(nums))
	}
	return
}

func SumAllTails(slices ...[]int) (sums []int) {
	for _, nums := range slices {
		if len(nums) == 0 {
			sums = append(sums, 0)
		} else {
			sums = append(sums, Sum(nums[1:]))
		}
	}
	return
}
